//
//  ProductDetailView.swift
//  TanTan_Kotlin
//
//  Created by EDY on 5/26/25.
//

import SwiftUI

struct ProductDetailView:View {
    @EnvironmentObject var data:ShareProducts
    var product: Product
    
    
    var body: some View {
        VStack {
            Image(systemName: product.imageName)
                .resizable()
                .frame(width: 100,height: 100)
                .cornerRadius(10)
                .padding()
            Text(product.name)
                .font(.largeTitle)
                .padding()
            Text("\(product.price, specifier: "%.2f") 元")
                .font(.title)
                .padding()
            Text(product.description)
                .padding()
            Button("加入购物车"){
                data.cart.append(product)
            }
            .padding()
            .background()
            .foregroundColor(.blue)
            .cornerRadius(10)
        }
        .navigationTitle(product.name)
    }
}

